/** 路由配置 */
import Vue from "vue";
import VueRouter from "vue-router";

// 导入试图组件

import Layout from '@/layout';
import Index from '@/layout/main/views/index';
import ArticleShow from '@/layout/main/views/articleShow';
import ArticleForm from '@/layout/main/views/articleForm';
import Login from '@/layout/main/views/login';
import Register from '@/layout/main/views/register';
import Uc from '@/layout/main/views/uc';

// 启用路由
Vue.use(VueRouter);

function buildRoutes(){
    let routers = [
        {
            path: "/",
            redirect: '/index',
        },
        {
            path: '/',
            component: Layout,
            children: [
                {
                    path: "index",
                    component: Index
                },
                {
                    path: "show/:id",
                    props: true,
                    component: ArticleShow
                },
                {
                    path: "form",
                    component: ArticleForm
                },
                {
                    path: "form/:id",
                    props: true,
                    component: ArticleForm
                },
                {
                    path: "login",
                    component: Login
                },
                {
                    path: "register",
                    component: Register
                },
                {
                    path: "uc",
                    component: Uc
                }
            ]
        }
    ];
    return routers;
}


const routers = buildRoutes();

// 路由对象
export default new VueRouter({
    // mode: 'history', // 去掉url中的# 
    routes: routers
});
